/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package beans;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;

/**
 *
 * @author DAHER
 */
public class AdminPais {
  static  String consulta;
public static ArrayList<String> getPaises() throws SQLException{
    consulta="select nombre from pais";
   ResultSet listar=Conexion.consultar(consulta);
   ArrayList<String>lista=new ArrayList<String>();
   while(listar.next()){
         lista.add(listar.getString("nombre"));
   }
   listar.close();
   return lista;
}
public static int getIdPais(String nom,Connection conect) throws SQLException{
   PreparedStatement consulta=conect.prepareStatement("select id_pais from pais where nombre=?");
   consulta.setString(1,nom);
   ResultSet result=consulta.executeQuery();
   int idP=0;
  
   if(result.next()){
   idP=result.getInt("id_pais");}
   result.close();
   return idP;
}
public static String getPais(int cod,Connection conect) throws SQLException{
        
        PreparedStatement consult=conect.prepareStatement("Select nombre from pais where id_pais=?");
        consult.setInt(1,cod);
        ResultSet resultado=consult.executeQuery();    
    String nombre="";    
    if(resultado.next()){
    nombre =resultado.getString(1);}
    resultado.close();
    return nombre;
}
}
